<?php
/**
 * Created by JetBrains PhpStorm.
 * User: ttp
 * Date: 5/7/11
 * Time: 9:08 AM
 * To change this template use File | Settings | File Templates.
 */
 
class Map_Model_Point extends App_Db_Table
{
    protected $_name = 'map_point';
    protected $_primary = 'point_pid';

    public function getCnt($params)
    {
        $select = $this->select();
        $select->from($this->_name, new Zend_Db_Expr('COUNT(*) as cnt'));

        return $this->getAdapter()->fetchOne($select);
    }

    public function getList($params)
    {
        $select = $this->select();
        $cols = array('point_pid', 'point_name', 'is_public');
        $select->from($this->_name, $cols);

        /* Limit */
        $limit = intval($params['rows']);
        $page = intval($params['page']);
        $offset = ($page - 1) * $limit;
        $select->limit($limit, $offset);

        $rows = $this->fetchAll($select);
        return $this->toJqGrid('point_pid', $rows->toArray());
    }
}